<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */

/**
 * 定时执行的任务方法列表
 * 营销->商品促销 自动删除商品 促销 标签 karson 20171010
 * @auther shopex ecstore dev dev@shopex.cn
 * @version 0.1
 * @package ectools.lib.misc
 */
class b2c_statistics_autosalesgoods extends base_task_abstract implements base_interface_task{

	function exec($params=null) {
		logger::info('------进入定时执行的任务方法列表--------');
		//自动删除商品促销失效商品标签
		$objCat = app::get("b2c")->model('goods_cat');
		$sqlproduct = " delete from  sdb_desktop_tag_rel where app_id='b2c' and tag_type='goods' and  tag_id=2 
		and rel_id in(select goods_id from sdb_b2c_goods_promotion_ref where unix_timestamp(now())>to_time and status =true);";
		logger::info($sqlproduct);
        $orderres = $objCat->db->exec($sqlproduct);

        //自动删除订单促销失效 商品标签
		$sql="select * from  sdb_b2c_sales_rule_order where unix_timestamp(now()) > to_time and status =true;";
		$promotionrefdata = $objCat->db->select($sql);

		if($promotionrefdata){
			foreach ($promotionrefdata as $key => $value) {

				$aResult = unserialize($value['conditions']);
               // var_dump($aResult['conditions'][0]['conditions'][0]['value']);
				$delsql= " delete from  sdb_desktop_tag_rel where app_id='b2c' and tag_type='goods' and  tag_id=2 
				and rel_id =".$aResult['conditions'][0]['conditions'][0]['value'];

				$deldata =$objCat->db->exec($delsql);

			}

		}

 



	




}

}
